package com.huixh.train.business.controller.admin;

import com.huixh.train.business.req.TrainSeatQueryReq;
import com.huixh.train.business.req.TrainSeatSaveReq;
import com.huixh.train.business.resp.TrainSeatQueryResp;
import com.huixh.train.business.service.TrainSeatService;
import com.huixh.train.common.resp.PageResult;
import com.huixh.train.common.resp.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author huixh
 */
@Validated
@RestController
@RequestMapping("/admin/trainSeat")
@Tag(name = "座位管理", description = "座位管理")
public class TrainSeatController {
    @Resource
    private TrainSeatService trainSeatService;

    @PostMapping("/save")
    @Operation(summary = "新增座位", method = "POST")
    public Result<?> save(@RequestBody @Valid TrainSeatSaveReq saveParams) {
        trainSeatService.save(saveParams);
        return Result.success();
    }

    @PostMapping("/quest-list")
    @Operation(summary = "查询座位列表", method = "POST")
    public PageResult<List<TrainSeatQueryResp>> query(@RequestBody @Valid TrainSeatQueryReq queryParams) {
        return trainSeatService.queryList(queryParams);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除座位", method = "DELETE")
    public Result<?> deleteById(@NotNull @PathVariable(name = "id") Long id) {
        trainSeatService.delete(id);
        return Result.success("删除成功");
    }
}